﻿using System;
using System.Web;
using System.Security.Cryptography;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.IO;

namespace   NxPartyAffairsOpen.Helpers
{
    public class UtilHelper
    {
        public static string ReturnStr(string iStr)
        {
            if (iStr == null)
                return "";
            iStr = iStr.Replace("['']", "'");
            iStr = iStr.Replace("[_]", "_");
            iStr = iStr.Replace("[%]", "%");
            iStr = iStr.Replace("[<]", "<");
            iStr = iStr.Replace("[>]", ">");
            return iStr;
        }

        public static string ReplaceStr(string iStr)
        {
            if (iStr == null)
                return "";
            iStr = iStr.Replace("'", "''");         
            iStr = iStr.Replace("%", "%%");          
            return iStr;
        }
        public static void WriteLog(string Log)
        {
            string dic = "d:\\log";
            if (!dic.EndsWith("\\"))
                dic = dic + "\\";
            dic += "log\\";
            if (!Directory.Exists(dic))
            {
                Directory.CreateDirectory(dic);
            }


            string FileName = dic + DateTime.Now.ToString("yyyyMMdd") + ".log";
            FileStream fs = new FileStream(FileName, FileMode.Append);
            StreamWriter streamWriter = new StreamWriter(fs);
            streamWriter.BaseStream.Seek(0, SeekOrigin.End);
            streamWriter.WriteLine(DateTime.Now.ToString()+" "+ Log);
            streamWriter.Flush();
            streamWriter.Close();

        }
     
    }
}
